from flask import Blueprint,jsonify

from app.models import User
from app import db

user = Blueprint("user",__name__)

@user.route('/user')
def user_func():
    user_obj = User(name='Jack')
    db.session.add(user_obj)  # 插入数据
    db.session.commit()  # 提交数据
    return '这是user蓝图页面'


@user.route('/user_list')
def user_func1():
    res = User.query.first()  # 查询
    ret = {
        "username":res.name
    }
    return jsonify(ret)
